package com.yyyyy.java.util.java.java;

import java.util.Scanner;

public class ATM {
    public static void main(String[] args) {

        Scanner scn = new Scanner(System.in);

        double banlance = 0;

        while (true) {
            System.out.println("=========ATM========");
            System.out.println("1、存款");
            System.out.println("2、取款");
            System.out.println("3、显示余额");
            System.out.println("4、退出");
            System.out.println("请选择(1-4)：");

            int res = scn.nextInt();//等于用户录入 数字选项

            System.out.println("您选择的是----》" + res);

            if (res == 1) {
                //存款
                System.out.println("请输入存款金额");
                double price = scn.nextDouble();

                banlance = banlance + price;//


            } else if (res == 2) {
                //取款
                System.out.println("请输入取款金额");
                double price2 = scn.nextDouble();


                if (price2 > banlance) {

                    System.out.println("当前余额为:" + banlance + "---->余额不足");


                } else if (price2 < 0) {
                    System.out.println("取款金额不合法");

                } else {
                    banlance = banlance - price2;

                }


            } else if (res == 3) {
                //显示余额

                System.out.println("当前余额为:" + banlance);

            } else if (res == 4) {
                //退出程序
                break;

            }

        }


    }


    }
